package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingTheCapturedTextOfAGroupWithinAPattern {
	public static void main(String[] args) {
		String patternStr = "<(\\S+?).*?>(.*?)</\\1>";
		Pattern pattern = Pattern.compile(patternStr);
		Matcher matcher = pattern.matcher("");

		matcher.reset("test this is test xx <tag a=b> yy test test</tag> zz");

		boolean matchFound = matcher.find();
		System.out.println(matchFound);
		String tagname = matcher.group(1);
		System.out.println(tagname);
		String contents = matcher.group(2);
		System.out.println(contents);

		matcher.reset("xx <tag> yy </tag0>");
		matchFound = matcher.find();
	}
}
